import request from '@/utils/request'

export function getRoutes(roleId) {
  return request({
    url: 'system/role/selectMenuListByRoleId',
    method: 'get',
     params: { roleId }
  })
}

export function getMenuList() {
  return request({
     url: 'system/menu/getMenuList',
     method: 'get'
  })
}

export function getRoles() {
  return request({
    url: 'system/role/allRoleList',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: 'system/role/insertRole',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'delete'
  })
}

export function saveRoleMenus(roleId, menus) {
  return request({
   url: 'system/role/saveRoleMenus',
    method: 'post',
    data:{
      id:roleId,
      menuList:menus
    }
  })
}
